import sys

from PyQt5.uic import *
from PyQt5.QtWidgets import *

from DatabaseInteraction import DatabaseInteraction


class ComboBowDialog(QDialog):
    def __init__(self):
        super(ComboBowDialog, self).__init__()
        self.ui = loadUi(r'ui/comboboxdialog.ui', self)
        self.database_interaction = DatabaseInteraction()
        self.class_list = self.database_interaction.get_all_class()
        self.init_ui_set()
        self.init_ui_connect()

    def init_ui_set(self):
        self.init_combo_box()

    def init_ui_connect(self):
        self.ui.acceptButton.clicked.connect(self.accept_button)
        self.ui.rejectButton.clicked.connect(self.reject_button)

    def init_combo_box(self):
        for i in self.class_list:
            self.ui.classBox.addItem(i)

    def reject_button(self):
        self.ui.close()

    def accept_button(self):
        self.ui.close()


if __name__ == '__main__':
    app = QApplication(sys.argv)
    window = ComboBowDialog()
    window.show()
    sys.exit(window.exec_())
